from ..ui_base import LikeSpiderUINode

class AudioExport(LikeSpiderUINode):
    """
    Save audio with custom filename, bitrate and format (.mp3, .wav, .flac).
    """

    UI_CONFIG = {
        "inputs": [
            {"name": "filename", "type": "string", "default": "track"},
            {"name": "bitrate", "type": "select", "options": [64, 128, 192, 256, 320], "default": 192},
            {"name": "format", "type": "select", "options": ["mp3", "wav", "flac"], "default": "mp3"},
            {"name": "audio", "type": "audio"}
        ]
    }

    def run(self, filename, bitrate, format, audio):
        self.save_audio_with_ffmpeg(audio_data=audio, filename_base=filename, format=format, bitrate=bitrate)
        return (audio,)
